Log In  
[back to top]


Cart #strdsum-0 | 2023-02-02 | Code ▽ | Embed ▽ | No License
6

Feature Overview

STRDSUM() sums two numerable strings.

  • The number of digits it can handle exceeds the 32-bit limit. (Probably as long as the system will allow.)
  • Match the string length to the longer of the two arguments.
  • Negative values and values after the decimal point cannot be handled.(Insert a period in the output result.)
  • This function consumes 63 Token.

This code may cause errors in versions prior to 0.2.5c.

?strdsum('32768','32768') -- 65536

?strdsum('500','000500') -- 001000

?strdsum('900109','123456') -- 1023565
6
1 comment



Hello @zep

One of my game players reported this.
It seems that Pico8 games downloaded from Steam sometimes fail to start when a controller is connected.

Target game in which the bug occurred.

https://store.steampowered.com/app/1448220/KONSAIRI/

Running environment

  • Apple silicon Mac.
  • Gamepad "Sony PlayStation® DualSense™ Wireless Controller" ----STORE PAGE.
  • Using Steam's controller linkage function (Bluetooth).
  • Exported cart pico8 version 0.2.2c (also occurs in 0.2.5e)

Crash report

https://docs.google.com/document/d/1u615ThHWhl_YEK8agfgb5EENnyzfXKkhnk_ach4XDgA/edit?usp=sharing

Thank you for your cooperation.

2
0 comments



In the screenshot, the pause menu does not appear.

But in the case of GIF output, the pause menu seems to appear.
(version 0.2.5c)

1
3 comments



Cart #knutil_bpack-2 | 2024-12-21 | Code ▽ | Embed ▽ | No License
14

Feature Overview

BPACK() pack the value of the bit specification with bit width.

  • If multiple bit values are specified, pack toward the most significant bit.
  • To start bit packing from the decimal point bit, set [number s] to a negative value.
  • If there are fewer bit width elements for the value to pack, the bit width elements are rotated.
  • This function consumes 38 Token.
v=bpack({8,4},0,0xff,0xb)
?tostr(v,1) -- 0x0bff.0000 (bit-left-shift:0)

v=bpack({8,4},4,0xff,0xb)
?tostr(v,1) -- 0x0bff.0000 (bit-left-shift:4)

This function is included in the KNUTIL library.

release note


v0.2a

  • changed the bit shift direction at the start of packing (negative is toward the decimal point).

v0.2

  • change the bit order to little endian.

v0.1

  • first release
0 comments



Cart #knutil_bunpack-3 | 2024-12-21 | Code ▽ | Embed ▽ | No License
14

Feature Overview

BUNPACK() slice the value with bit width.

  • by specifying the argument after [number w], a value of up to 32 bits can be sliced.
  • set [number s] to a negative value to start the slicing from the decimal point bit.
  • This function consumes 30 Token.
a,b=bunpack(0xf8,0,4,4) -- Value, First bit-shift, bit-width, ...[bit-width]
?a -- 8  (0x8)
?b -- 15 (0xf)

This function is included in the KNUTIL library.

release note


v0.2

  • change table storage order to little endian.

v0.1

  • first release
2
0 comments



Cart #knutil_tbfill-0 | 2022-09-12 | Code ▽ | Embed ▽ | No License
1

Feature Overview

TBFILL() Create a table by specifying an index number.

  • Create the table with the specified minimum and maximum indices and fill it with the value of the first argument.
  • Multi-dimensional tables can be created by adding minimum and maximum arguments.
  • This function consumes 30 Token.
-- one-dimensional table 
t=tbfill('yes',1,3)
?t[1]..' '..t[2]..' '..t[3].."\n\n"

-- two-dimensional table
t=tbfill('yes',1,2,1,3)
t[2][2]='no'
?t[1][1]..' '..t[1][2]..' '..t[1][3]
?t[2][1]..' '..t[2][2]..' '..t[2][3]

This function is included in the KNUTIL library.

[ Continue Reading.. ]

1
0 comments



Cart #knutil_join-3 | 2024-12-27 | Code ▽ | Embed ▽ | No License
3

Feature Overview

JOIN() Join strings with a delimiter.

  • Joins the argument strings with the specified delimiter.
  • This function consumes 25 Token.
?join('====','----','----','----','----\n')

?join(' ',unpack({'test','[join]','is','ok!\n\n'}))

?join('\faâ—†\f6','c','o','m','p','l','e','t','e\n')

?join('\-e=\-e',unpack(split('----------------------------','')))

This function is included in the KNUTIL library.

release note


v0.3a

  • compatible with v0.2(a nil argument returns an empty string)

v0.3

  • eliminate recursive functions (often resulting in out-of-memory)

v0.2

  • variable argument support by tuple

v0.1

  • first release
3
6 comments



Cart #knutil_ttable-2 | 2023-07-28 | Code ▽ | Embed ▽ | No License
1

Feature Overview

TTABLE() returns the table if the argument is a table.

  • Returns FALSE if not a table.
  • Use when table or string determination is required.
    • e.g., when using a string for initialization and replacing it with a table
    • Simultaneously check the type and reference the contents inline, as in type(tbl)=='table' and tbl.
  • This function consumes 10 Token.
tbl = '1 5 10' -- Default value.

tbl = ttable(tbl) or split(tbl, ' ') -- tbl = {1, 5, 10}

----
----

-- Thereafter, the tbl is not initialized even if there are changes to the elements of the tbl.
tbl = ttable(tbl) or split(tbl, ' ')

This function is included in the KNUTIL library.

[ Continue Reading.. ]

1
1 comment



Cart #knutil_replace-1 | 2023-07-27 | Code ▽ | Embed ▽ | No License
6

Feature Overview

REPLACE() Replaces the specified string with the specified string.

  • The first argument string replaces all matches to the second argument string with the third argument string.
  • After the fourth and fifth words, you can further specify the search match and the words to be replaced.
  • This function consumes 58 Token.
--"str" becomes "string for replace".
str = replace('[test] for replace', '[test]', 'string') 

This function is included in the KNUTIL library.

release note


v0.2

  • multiple substitutions can be made with a single function call.

v0.1

  • first release

6
5 comments



Cart #tuple_sum-0 | 2022-07-26 | Code ▽ | Embed ▽ | No License
3

Feature Overview

SUM() returns the sum of the numbers in the given arguments.

  • If the argument contains nil or false, the result will not be correct.
  • If too many arguments are given, Out of memory is returned. (In the sample, up to 710 arguments)
  • This function consumes 15 Token.

If you are concerned about some of the problems, consider using the "More Argments Ver" code.

--more argments ver(17 token)
function sum(a,...)
 foreach({...},function(v)
  a+=v
 end)
 return a
end

Other tuple trick code: INRNG()

3
0 comments



[sfx]

[24x24]

This is one of the pieces of music played in my own game. ☺

KONSAIRI BGM Posts

[ Continue Reading.. ]

3
0 comments



Cart #knutil_inrng-2 | 2022-06-30 | Code ▽ | Embed ▽ | No License
2

Feature Overview

INRNG() Tests if the value is between the lowest and highest values.

  • Tests that the specified value is within a range.
  • This function consumes 10 Token.
--[true] in range value
inrng(5,1,10) 

--[true] lowest range value
inrng(1,1,10)

--[true] highest range value
inrng(10,1,10)

--[false] out of range value
inrng(0,1,10)

--Player:1 any key
inrng(btn(),0x1,0xff)

--Player:2 any key
inrng(btn(),0x100,0xff00)

This function is included in the KNUTIL library.

release note


v0.2

  • change arguments to a tuple

v0.1

  • first release

2
1 comment



One-off characters [8 chars of raw binary data] print unnaturally.

Or I may not understand this feature.
I was aware that "\^.00000000" would print nothing.

2 comments



Setting Tab stop controll code to 0 and outputting tab characters at the same time causes pico-8 crash.

pico-8 version:0.2.4b

print("\^s0\t")
1 comment



Cart #rceach-0 | 2022-03-30 | Code ▽ | Embed ▽ | No License
1

Feature Overview

RCEACH() performs a two-dimensional loop in a single function.

  • The rectangle value arguments correspond to [table] {x,y,w,h} and [string] "x y w h".
  • You can refer to the current x and y values in the specified function.
  • This function consumes 50 Token.
rceach({16,16,32,32},function(x,y,r)
 local c=(x+y)%8+8
 pset(x,y,c)
end)

One of KNUTIL's functions, the object generated by EXRECT(), has a rectangle value format to be used for the RCEACH() argument.
may want to Use DMP() if check the converted table.
This function is included in the KNUTIL library.

1
4 comments



Cart #tablemap-1 | 2023-05-28 | Code ▽ | Embed ▽ | No License
1

Feature Overview

TMAP(), like foreach(), applies the function of the second argument to each element of the table.

  • Usage is almost the same as foreach(), plus index values can be referenced within the function.
  • The specified table is returned. (TMAP() nested functions can be applied multiply)
  • The return value in the function specified in the argument can update each element of the table.
  • This function consumes 31 Token.
local t={
 'toast'
 ,'letus'
 ,'bacon'
 ,'cheese'
}
t=tmap(t, function(v,i)
 ?i..'..'..v
end)

--------

t=tmap(t, function(v,i)
 v='super★'..v
 ?i..'..'..v
 return v
end)

--------

t=tmap({
 'shield'
 ,'armor'
 ,'sword'
 ,'ring'
}, function(v,i)
 v=t[i]..'•'..v

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=77195#p)
1
1 comment



Cart #combine_table-0 | 2022-03-15 | Code ▽ | Embed ▽ | No License
1

Feature Overview

COMB() combines two tables to create a hash table.

  • Returns the joined table.
  • The two arguments must be tables of index arrays.
  • The argument is nondestructive.
  • Hash tables are not in constant order. (This is a Lua specification.)
  • This function consumes 26 Token.
local keys={'name','species','home','skill'}
local values={'ruth','fox','port town','kon-psi'}

local charcter=comb(keys,values)

may want to Use DMP() if check the converted table.
This function is included in the KNUTIL library.

1
0 comments



Cart #concat___table-0 | 2022-03-11 | Code ▽ | Embed ▽ | No License
2

Feature Overview

CAT() concatenates two or more tables.

  • The second and subsequent arguments are added to the table elements of the first argument.
  • Returns a concatenated table.
  • The table used for the first argument is updated. (destructive)
  • This function consumes 39 Token.
local tbl_1 = {'a'}
local tbl_2 = {'b', 'c'}

cat(tbl_1, tbl_2)

?tbl_1[1] -- a
?tbl_1[2] -- b
?tbl_1[3] -- c

-- Only primary elements can be cloned by specifying an empty table for the first argument.
local tbl = {1, 2, 3}
local tbl_dup = cat({}, tbl)
tbl[1] = 256

?tbl_dup[1] -- 1
?tbl_dup[2] -- 2
?tbl_dup[3] -- 3

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=88288#p)
2
0 comments



Hello.

I want to use the clipboard to paste SFX data to another console as shown in the image below.
With the current (0.2.4b) function of PICO-8, you can only paste SFX data on the same console.
It would be simpler to share sound effects if they could be pasted to the clipboard in a format like
[gfx] wwhhpp... [/gfx)

1
3 comments



In what situations do you use these conversions?

hexnumber = '3xz'

--A
tonum(hexnumber,1)       : 768 (0x0300.0000)

--B
tonum("0x"..hexnumber,4) : 0 (0x0000.0000)

--C
tonum('0x'..hexnumber)   : -- NO VALUE --([nil])

Example
I want "nil" to be returned when I use a character as an identifier. Therefore, I use the "C" conversion.

hexstr = '108000789$'
hexval = TONORM(hexstr) -- Normalize the value [number boolian nil], otherwise it remains a string.
hextable = {}

if type(hexval) == 'string' then

 foreach(split(hexstr, 3), function(v)
  add(hextable, tonum('0x' .. v))
 end)

end

-- Handle hexadecimal conversions without being converted to numbers by normalization.
-- Only the value of number is stored in the hextable.
-- "$" is not stored.
3 comments





Top    Load More Posts ->